package com.greateamd.timetableasy.client.widgets.campus;

import java.util.List;

import com.google.gwt.core.client.GWT;
import com.google.gwt.uibinder.client.UiConstructor;
import com.google.gwt.user.client.rpc.AsyncCallback;
import com.greateamd.timetableasy.client.services.promotion.PromotionService;
import com.greateamd.timetableasy.client.services.promotion.PromotionServiceAsync;
import com.greateamd.timetableasy.client.services.util.ServerCall;
import com.greateamd.timetableasy.domain.Promotion;

public class PromotionOfCampusManagerListBox extends PromotionListBox{

	public @UiConstructor PromotionOfCampusManagerListBox(boolean autoLoad) {
		super(autoLoad);
		if(autoLoad){
			loadPromotion();
		}
	}	

	public void loadPromotion() {
		final PromotionServiceAsync promotionService = GWT.create(PromotionService.class);
		new ServerCall<List<Promotion>>() {

			@Override
			protected void callService(AsyncCallback<List<Promotion>> asyncCallback) {
				promotionService.getAllOfCampusManager(asyncCallback);
			}

			@Override
			public void onSuccess(List<Promotion> list) {
				setPromotions(list);
				showList();
			}
		}.call();
	}
}
